using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Configuration;

namespace BaseBL
{
    public static class GlobalBL
    {
        static private Logger logger;

        static public void Initialize(Logger logger)
        {
            GlobalBL.SetLogger(logger);
        }
        
        static public void SetLogger(Logger logger)
        {
            Hope(GlobalBL.logger == null, "Call GlobalBL.SetLogger() only once.");
            GlobalBL.logger = logger;
        }

        static public Logger Logger
        {
            get
            {
                Hope(logger != null, "Call GlobalBL.SetLogger() first.");
                return logger;
            }
        }

        static public void Hope(bool condition)
        {
            Hope(condition, "");
        }

        static public void Hope(bool condition, string message)
        {
            if (!condition)
            {
                throw new BaseBLException(message);
            }
        }

        static public bool DebugEnabled()
        {
            return ConfigurationManager.AppSettings["DebugOutput"] == "true";
        }
          
    }
}
